package com.scau.databaseexam.DAO;


import com.scau.databaseexam.beans.Item;
import org.apache.ibatis.annotations.*;

import java.util.ArrayList;
import java.util.Date;
import java.util.List;

@Mapper
public interface ItemDao {
    @Select("select * from item where uid=#{uid}")
    @Results({
            @Result(column = "uid",property = "uid"),
            @Result(column = "id",property = "id"),
            @Result(column = "name",property = "name"),
            @Result(column = "image",property = "image"),
            @Result(column = "script",property = "script"),
            @Result(column = "date",property = "date")
    })
    public ArrayList<Item> selectItems(String uid);

    @Select("select * from item where uid=#{uid} and id=#{id}")
    public Item selectItem(String uid,String id);

    @Insert("insert into item(uid,id,name,image,script,date) values(#{uid},#{id},#{name},#{image},#{script},#{date});")
    public void insertItem(Item item);

    @Delete("delete from item where uid=#{uid} and id=#{id}")
    public void deleteItem(String uid, String id);

    @Update("update item set name=#{name},script=#{script},date=#{date} where uid=#{uid} and id=#{id}")
    public void updateItem(String uid,String id,String name, String script, Date date);

}
